#ifndef TEXTSPINBOX_H
#define TEXTSPINBOX_H

#include <QAbstractSpinBox>
#include <QStringList>
#include <QLineEdit>
#include <QSpinBox>
#include <QFlags>
#include <QMap>
#include <QColor>

class TextSpinBox : public QAbstractSpinBox
{
    Q_OBJECT
public:

    /** Default constructor*/
    TextSpinBox(QWidget* parent = 0);

    ~TextSpinBox();

    /** Set up the list that the text box loops through and the current text*/
    inline void setList(const QStringList& list) { m_list = &list; }
    void setText(const QString& text);
    void init(const QStringList& list, const QString& text);


    /** Allows other objects to access the current display text.*/
    inline QString displayText() { return m_list->at(m_index); }

    /** Re-implementation of functions from QAbstractSpinBox to tell the object
      how to spin.
      */
    void stepBy(int steps);
    StepEnabled stepEnabled() const;

public slots:
    void colorChangedSlot(QString text);

signals:
    void colorChanged(QString text);
    void textChanged();

private:

    void setColourMap();
    const QStringList* m_list;
    int m_index;

    QMap<QString, QColor> m_colorMap;

};


#endif // TEXTSPINBOX_H
